#include "apue.2e/include/apue.h"
// #include <sys/types.h>
// #include <sys/stat.h>
// #include <fcntl.h>
// #include <stdio.h>

int main(int argc, char* argv[]){
	struct stat buf;
	char* ptr;
	for(int i=1; i<argc; i++){
		printf("%s:",argv[i]);

		if(lstat(argv[i], &buf) == -1){
			printf(" lstat error\n");
			continue;
		}

		if (S_ISREG(buf.st_mode)) 			ptr = "regular";
		else if (S_ISDIR(buf.st_mode))		ptr = "directory";
		else if (S_ISCHR(buf.st_mode))		ptr = "character special";
		else if (S_ISBLK(buf.st_mode))		ptr = "block special";
		else if (S_ISFIFO(buf.st_mode))		ptr = "fifo";
		else if (S_ISLNK(buf.st_mode))		ptr = "symbolic link";
		else if (S_ISSOCK(buf.st_mode))		ptr = "socket";
		else								ptr = "** unknown mode **";
		printf("%s\n", ptr);
	}

	exit(0);
}

// ./a.out /etc/passwd /etc /dev/initctl /dev/log /dev/tty  /dev/scsi/host0/bus0/target0/lun0/cd /dev/cdrom